home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / f90 / ffseek.z / ffseek
Text File  |  1998-10-30  |  6KB  |  138 lines

  1. FFSEEK(3C)                                            Last changed: 2-18-98
  2.  
  3.  
  4. NNAAMMEE
  5.      ffffsseeeekk, ffffbbkksspp, ffffsseeeekkff, ffffbbkkssppff - Repositions a flexible file I/O
  6.      file
  7.  
  8. SSYYNNOOPPSSIISS
  9.      ##iinncclluuddee <<ffffiioo..hh>>
  10.  
  11.      ##iinncclluuddee <<uunniissttdd..hh>>
  12.  
  13.      UNICOS and UNICOS/mk systems:
  14.  
  15.         iinntt ffffsseeeekk ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
  16.  
  17.         iinntt ffffbbkksspp ((iinntt _f_d [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
  18.  
  19.      IRIX systems:
  20.  
  21.         ooffff__tt ffffsseeeekk ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e));;
  22.  
  23.         iinntt ffffbbkksspp ((iinntt _f_d));;
  24.  
  25.      All systems:
  26.  
  27.         ooffff__tt ffffsseeeekkff ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e,,  ssttrruucctt ffffssww **ssttaatt));;
  28.  
  29.         iinntt ffffbbkkssppff ((iinntt _f_d,, ssttrruucctt ffffssww **_s_t_a_t));;
  30.  
  31. IIMMPPLLEEMMEENNTTAATTIIOONN
  32.      UNICOS, UNICOS/mk, and IRIX systems
  33.  
  34. DDEESSCCRRIIPPTTIIOONN
  35.      The ffffsseeeekk function provides flexible file I/O (FFIO) positioning
  36.      capability similar to that of llsseeeekk(2).  In addition to the
  37.      functionality of llsseeeekk, ffffsseeeekk provides access to limited positioning
  38.      on blocked files and record-oriented files.  Specifying ffffsseeeekk((ffdd,, 00,,
  39.      00)) always rewinds a file to its initial point, regardless of whether
  40.      the file is stream, blocked, or tape.  When using the ssyyssccaallll layer,
  41.      this function cannot be used to position a tape.
  42.  
  43.      This function allows programs to be written so that their I/O can be
  44.      controlled by the aassggccmmdd(1) or aassssiiggnn(1) command.  Both native and
  45.      foreign record-oriented I/O, multifile datasets, and
  46.      performance-oriented layers (such as SDS resident layers and
  47.      memory-resident layers) are available with this mechanism.
  48.  
  49.      Function ffffbbkksspp allows you to perform a backspace operation on those
  50.      FFIO layers that support it.  Currently, this is limited to ccooss, ttaappee,
  51.      ff7777, and tteexxtt.
  52.  
  53.      Arguments are as follows:
  54.  
  55.      _f_d       Number returned by ffffooppeenn(3C).
  56.  
  57.      _p_o_s      Byte position requested.
  58.  
  59.      _w_h_e_n_c_e   Specifies one of the following values (defined in header file
  60.               ssttddiioo..hh):
  61.  
  62.               0 or SSEEEEKK__SSEETT       Sets the pointer to the value of _p_o_s.
  63.                                   _p_o_s must be a non-negative integer.
  64.                                   (Special case:  ffffsseeeekk((ffdd,, 00,, 00)) ==
  65.                                   rreewwiinndd)
  66.  
  67.               11 or SSEEEEKK__CCUURR       Sets the pointer to the current position,
  68.                                   plus or minus **_a_r_g.  This is supported
  69.                                   only in layers that are not
  70.                                   record-oriented; layers are specified to
  71.                                   aassssiiggnn --FF as follows:  ssyyssccaallll, ssddss, mmrr
  72.                                   (memory resident), ccaacchhee, ccaacchheeaa, bbuuffaa,
  73.                                   eerr9900.
  74.  
  75.               22 or SSEEEEKK__EENNDD       Sets the pointer to the end of the file,
  76.                                   minus _p_o_s.  _p_o_s must be a non-negative
  77.                                   integer.  Not all layers support this
  78.                                   option.  (Special case: ffffsseeeekk((ffdd,, 00,, 22))
  79.                                   == position just in front of the EOD.)
  80.  
  81.      ssttaatt     Pointer to the ffffssww status return structure.
  82.  
  83. RREETTUURRNN VVAALLUUEESS
  84.      The return value is the current position in the file after the seek.
  85.      Upon successful completion, a non-negative value is returned.
  86.      Otherwise, -1 is returned, and, if the _s_t_a_t parameter is passed, the
  87.      error value is found in ssttaatt..ssww__eerrrroorr.  If the _s_t_a_t parameter is not
  88.      provided, the error code is found in eerrrrnnoo.
  89.  
  90. EEXXAAMMPPLLEESS
  91.           #include <stdlib.h>
  92.           #include <fcntl.h>
  93.           #include <stdio.h>
  94.           #include <ffio.h>
  95.  
  96.           main()
  97.           {
  98.                size_t ret;
  99.                int fd, i, j;
  100.                off_t fret;
  101.  
  102.                fd = ffopen("data", O_RDWR | O_CREAT, 0666);
  103.  
  104.                for (i = 0 ; i < 1000 ; i++)
  105.                {
  106.                     ret = ffwrite(fd, &i, sizeof(i));
  107.                     if (ret < 0) abort();
  108.                }
  109.  
  110.                for (i = 0 ; i < 10 ; i++)
  111.                {
  112.                     fret = ffseek(fd, i * sizeof(j) * 100, SEEK_SET);
  113.                     if (fret < 0) abort();
  114.                     ret = ffread(fd, &j, sizeof(j));
  115.                     if (ret < 0) abort();
  116.                     printf("Value is %d at word %d\n", j, i*100);
  117.                }
  118.           }
  119.  
  120.      Output from the previous program is as follows:
  121.  
  122.           Value is 0 at word 0
  123.           Value is 100 at word 100
  124.           Value is 200 at word 200
  125.           Value is 300 at word 300
  126.           Value is 400 at word 400
  127.           Value is 500 at word 500
  128.           Value is 600 at word 600
  129.           Value is 700 at word 700
  130.           Value is 800 at word 800
  131.           Value is 900 at word 900
  132.  
  133. SSEEEE AALLSSOO
  134.      eerrrrnnoo..hh(3C), ffffcclloossee(3C), ffffooppeenn(3C), ffffrreeaadd(3C), ffffwwrriittee(3C)
  135.  
  136.      _A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _L_i_b_r_a_r_y _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
  137.      SR-2165, for the printed version of this man page.
  138.